﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class TestGetLocation : MonoBehaviour {

    Button startBtn;
    Button stopBtn;
    Text resultText;

    void Start () {
        startBtn = transform.Find("startBtn").GetComponent<Button>();
        stopBtn= transform.Find("stopBtn").GetComponent<Button>();
        resultText = transform.Find("resultText").GetComponent<Text>();

        AndroidUtil util = new AndroidUtil(gameObject, "_CallBack");

        startBtn.onClick.AddListener(()=> {
            startBtn.gameObject.SetActive(false);
            stopBtn.gameObject.SetActive(true);

            util.StartLocation();
        });

        stopBtn.onClick.AddListener(() => {
            stopBtn.gameObject.SetActive(false);
            startBtn.gameObject.SetActive(true);

            util.StopLocation();
        });
    }

    public void _CallBack(string locationResult)
    {
        resultText.text = locationResult;
    }
}
